Skip to main content

Swap Request

Generate a transaction payload for a swap request.

Endpoint

Method: POST

https://testnet.api.euclidprotocol.com/api/v1/execute/swap

Examples

curl -X 'POST'   'https://testnet.api.euclidprotocol.com/api/v1/execute/swap'   -H 'accept: application/json'   -H 'Content-Type: application/json'   -d '{
    "amount_in": "100000000000000000",
    "asset_in": {
      "token": "bsc",
      "amount": "100000000000000000",
      "token_type": {
        "smart": {
          "contract_address": "0x3246d25b42f6b3deca5b40334775fa4d6e333010"
        }
      }
    },
    "slippage": "500",
    "cross_chain_addresses": [
      {
        "user": {
          "address": "0x887e4aac216674d2c432798f851c1ea5d505b2e1",
          "chain_uid": "0g",
          "amount": "50000000"
        },
        "limit": {
          "less_than_or_equal": "3563664058479"
        },
        "preferred_denom": {
          "native": {
            "denom": "bsc"
          }
        }
      }
    ],
    "partnerFee": {
      "partner_fee_bps": 10,
      "recipient": "0x8ed341da628fb9f540ab3a4ce4432ee9b4f5d658"
    },
    "sender": {
      "address": "0x887e4aac216674d2c432798f851c1ea5d505b2e1",
      "chain_uid": "neuron"
    },
    "swap_path": {
      "path": [
        {
          "route": [
            "euclid",
            "bnb"
          ],
          "dex": "euclid"
        }
      ]
    }
  }'
{
  "type": "cosmwasm",
  "sender": {
    "chain_uid": "neuron",
    "address": "0x887e4aac216674d2c432798f851c1ea5d505b2e1"
  },
  "contract": "euclid1aagn260yt7xtvq0jdecxu265zqzkc6mhc4glql2q2nmdsqwzmyzs8lfhhx",
  "chain_id": "neuron-1",
  "rpc_url": "https://rpc.neuron.euclidprotocol.com",
  "rest_url": "https://lcd.neuron.euclidprotocol.com",
  "msgs": [
    {
      "contractAddress": "0x3246d25b42f6b3deca5b40334775fa4d6e333010",
      "msg": {
        "send": {
          "amount": "100000000000000000",
          "contract": "euclid1aagn260yt7xtvq0jdecxu265zqzkc6mhc4glql2q2nmdsqwzmyzs8lfhhx",
          "msg": "eyJzd2FwI..."
        }
      },
      "funds": []
    }
  ],
  "meta": "{"asset_in_type":"smart","releases":[{"dex":"euclid","release_address":[{"chain_uid":"0g","address":"0x887e4aac216674d2c432798f851c1ea5d505b2e1","amount":"3563664058479"}],"token":"bnb","amount":""}],"swaps":{"path":[{"route":["euclid","bnb"],"dex":"euclid","chain_uid":"","amount_in":"100000000000000000","amount_out":"8152420272192926720"}]}}"
}
curl -X 'POST'   'https://testnet.api.euclidprotocol.com/api/v1/execute/swap'   -H 'accept: application/json'   -H 'Content-Type: application/json'   -d '{
  "amount_in": "100000000000000000",
  "asset_in": {
    "token": "codewizard.eucl",
    "amount": "100000000000000000",
    "token_type": {
      "smart": {
        "contract_address": "0x3246d25b42f6b3deca5b40334775fa4d6e333010"
      }
    }
  },
  "slippage": "500",
  "cross_chain_addresses": [
    {
      "user": {
        "address": "0x887e4aac216674d2c432798f851c1ea5d505b2e1",
        "chain_uid": "0g",
        "amount": "50000000"
      },
      "limit": {
        "less_than_or_equal": "3563664058479"
      },
      "native": {
        "denom": "euclid"
      }
    }
  ],
  "partnerFee": {
    "partner_fee_bps": 10,
    "recipient": "0x8ed341da628fb9f540ab3a4ce4432ee9b4f5d658"
  },
  "sender": {
    "address": "0x887e4aac216674d2c432798f851c1ea5d505b2e1",
    "chain_uid": "bsc"
  },
  "swap_path": {
    "path": [
      {
        "route": [
          "bnb",
          "euclid"
        ],
        "dex": "euclid",
        "amount_in": "100000000000000000",
        "amount_out": "635340"
      }
    ]
  }
}'
{
  "chain_id": "97",
  "contract": "0x62d8658a3d7c669943c95c781c220469e19beb47",
  "meta": "{"asset_in_type":"smart","releases":[{"dex":"euclid","release_address":[{"chain_uid":"0g","address":"0x887e4aac216674d2c432798f851c1ea5d505b2e1","amount":"3563664058479"}],"token":"euclid","amount":""}],"swaps":{"path":[{"route":["bnb","euclid"],"dex":"euclid","chain_uid":"","amount_in":"100000000000000000","amount_out":"635340"}]}}",
  "msgs": [
    {
      "chainId": "97",
      "to": "0x3246d25b42f6b3deca5b40334775fa4d6e333010",
      "data": "0x095ea7b30000000000000000000000006...",
      "value": "0x0"
    },
    {
      "chainId": "97",
      "to": "0x62d8658a3d7c669943c95c781c220469e19beb47",
      "data": "0x6e31c74900000000000000000000...",
      "value": "0x0"
    }
  ],
  "rest_url": "https://bsc-testnet.drpc.org",
  "rpc_url": "https://bsc-testnet.drpc.org",
  "sender": {
    "chain_uid": "bsc",
    "address": "0x887e4aac216674d2c432798f851c1ea5d505b2e1"
  },
  "type": "evm"
}

Parameters

tip

The dex field inside each swap_path step specifies which decentralized exchange (DEX) to use for that segment of the route. For example, setting "dex": "euclid" means the swap will use liquidity from Euclid's unified liquidity layer.

You can also route your swap through other supported DEXs by specifying their names, such as "dex": "osmosis" or "dex": "astroport".

These routes, including the exact sequence of tokens and DEXs to be used, are obtained by calling the Get Routes endpoint. The response will include one or more route options detailing the path and associated DEX for each hop. You should use the selected route in your actual swap call.

FieldTypeRequiredDescription
amount_instringYesAmount of the input token to be swapped.
asset_inTokenWithDenomYesInput token and its type (either native or smart).
slippagestringYesSlippage tolerance in basis points (e.g., "500" for 5%).
minimum_receivestringNoMinimum acceptable output amount for the swap.
cross_chain_addressesCrossChainUserWithLimit[]NoRecipients for the output asset. Priority is top-down. Defaults to the sender if omitted.
partnerFeePartnerFeeNoPartner fee configuration. Includes basis points and recipient.
senderCrossChainUserYesAddress and chain initiating the swap.
swap_pathSwapPathYesRouting path with token hops and DEX info. Use values from the Get Routes endpoint.
timeoutstringNoTimeout in seconds. Default is 60. Must be between 30 and 240.

SwapPath

FieldTypeRequiredDescription
pathobject[]YesSteps for the swap route, each defining a DEX and token route.

Each path object

FieldTypeRequiredDescription
routestring[]YesToken sequence for the step (e.g., ["usdc", "euclid", "eth"]).
dexstringYesDEX used for this step (e.g., "euclid", "osmosis").
chain_uidstringNoUID of the chain where this step is executed.
amount_instringNoInput amount for this step (usually calculated automatically).
amount_outstringNoEstimated output amount for this step.

PartnerFee

FieldTypeRequiredDescription
partner_fee_bpsnumberYesFee in basis points (e.g., 10 = 0.1%).
recipientstringYesAddress to receive the fee (typically on the same chain as sender).